<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('正式服务商列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <input type="hidden" name="posType" th:value="${pos_type}">
                        <input type="hidden" name="agentNum" th:value="${agent_num}">
                        <input type="hidden" name="sns" id="sns" th:value="${sns}">
                        <ul>
                            <li>sn编号：
                                <input type="text" name="machineNum"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var datas = [[${@dict.getType('agent_status')}]];
        var editFlag = [[${@permission.hasPermi('agentInfo:agentInfo:edit')}]];
        var prefix = ctx + "formalPos/branchPos";
        var sns = $("#sns").val().split(",")
        $(function() {
            var options = {
                showSearch: true,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                clickToSelect:true,
                pageSize: 10,
                pageList: [10, 25, 50, 100, 360],
                url: prefix + "/selectPos",
                modalName: "服务商申请",
                columns: [{
                    checkbox: true,
                    formatter: function (value, row, index) {
                        if(sns[0] == ''){
                            return {checked: true}
                        }
                        for(var i = 0;i<sns.length;i++){
                            if($.common.equals(sns[i], row.sn)){
                                return { checked : true}
                            } else {
                                if(i == sns.length){
                                    return { checked : false}
                                }
                            }
                        }
                    }
                },
                {
                    field: 'sn',
                    title: 'sn编号',
                }]
            };
            $.table.init(options);
        });
        function submitHandler(index, layero) {
            var rows = $.table.selectFirstColumns();
            if (rows.length == 0) {
                $.modal.alertWarning("请选择一条记录");
                return;
            }
            $.modal.close();
            // 父页面的变量

            parent.$('#sn').val($.table.selectColumns("sn"));
            parent.$('#count').val($.table.selectColumns("sn").length)
        }

    </script>
</body>
</html>